package org.scratchcrew.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "t_boards_data")
@AttributeOverrides(value = { @AttributeOverride(column = @Column(name = "board_data_id"), name = "id") })
public class BoardData extends BaseEntity {
	@Lob
	@Column(name = "board_data", nullable = false)
	private String boardData;

	@OneToOne(fetch = FetchType.EAGER)
	@JoinColumn(nullable = false, unique = true, name = "board_id")
	private Board board;

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "boardData")
	private Set<Scratch> scratches = new HashSet<Scratch>();
 
	public String getBoardData() {
		return boardData;
	}

	public void setBoardData(String boardData) {
		this.boardData = boardData;
	}

	public Board getBoard() {
		return board;
	}

	public void setBoard(Board board) {
		this.board = board;
	}

	public Set<Scratch> getScratches() {
		return scratches;
	}

	public void setScratches(Set<Scratch> scratches) {
		this.scratches = scratches;
	}
	
}
